package com.yanqu.road.logic.activity.foxcard.game.buff;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.entity.activity.foxcard.config.FoxCardBuffConfig;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardType;

public class FoxCardBuffBase implements FoxCardBuff{
    protected FoxBaseCard baseCard;
    protected FoxCardBuffConfig buffConfig;
    protected eFoxCardTriggerType triggerType;
    @Override
    public FoxCardBuff init(FoxCardBuffConfig buffConfig, FoxBaseCard baseCard, eFoxCardTriggerType triggerType) {
        this.buffConfig = buffConfig;
        this.baseCard = baseCard;
        this.triggerType = triggerType;
        return this;
    }

    protected boolean buffHandle(FoxCardGameLogic gameLogic) {
        return false;
    }

    @Override
    public void handle(FoxCardGameLogic gameLogic) {
        if (buffHandle(gameLogic)) {
            if (baseCard.getCardType() == eFoxCardType.HAND.getValue()) {//目前是手牌才统计
                Integer times = gameLogic.getGameData().getHistoryBuffTimesMap().getOrDefault(buffConfig.getId(), 0);
                gameLogic.getGameData().getHistoryBuffTimesMap().put(buffConfig.getId(), times + 1);

                gameLogic.dealCardEffect(eFoxCardTriggerType.BUFF_TRIGGER, (FoxHandCard) baseCard);
            }
        }
    }
}
